import React, { Component } from 'react'

export class Childrens extends Component {
    state = {
        count: 1
    }
    UNSAFE_componentWillMount() {
        console.log('我是子组件-componentWillMount')
    }
    componentDidMount() {
        console.log('我是子组件-componentDidMount')
    }
    // componentDidUpdate() {
    //     console.log('我是子组件-componentDidUpdate')
    // }
    click = () => {
        this.setState({
            count: 100
        })
    }
    render() {
        console.log('子组件-render')
        const { listData } = this.props
        return (
            <div>
                <h1>我是子组件</h1>
                <ul>
                    {
                        listData.map(item => (
                            <li key={ item.imgurl }>{ item.imgurl }</li>
                        ))
                    }
                </ul>
                <button onClick={this.click}>点击+{ this.state.count}</button>
            </div>
        )
    }
}

export default Childrens;
